﻿using Treca.Business;
using Treca.Util;
using Treca.WebEx.Business;
using Treca.WebEx.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Treca.WebEx.Base.Helper
{
    public static class JsConfigHelper
    {
        public static string GetPathJs()
        {
            var url=HttpContextCore.Current.Request.Path+ HttpContextCore.Current.Request.QueryString;
            Ibase_helpconfigBusiness _base_helpconfigBus=AutofacHelper.GetScopeService<Ibase_helpconfigBusiness>();
            var helper = _base_helpconfigBus.GetIQueryable().Where(t => t.HelpConfigUrl == url && t.HelpType == "JS" && t.StatusFlag == "1").FirstOrDefault();
            if (helper.IsNullOrEmpty())
            {
                return "";
            }
            else
            {
                return helper.HelpContent;
            }
        }
        public static IOperator @operator { get => AutofacHelper.GetScopeService<IOperator>(); }
        public static List<base_searchplan> GetSearchPlan()
        {
            var url = HttpContextCore.Current.Request.Path.ToString();
            Ibase_searchplanBusiness repository = AutofacHelper.GetScopeService<Ibase_searchplanBusiness>();
            var userid = @operator.UserId;
            var listret = repository.GetIQueryable().Where(t => t.url== url && t.userid == userid && t.StatusFlag == "1").ToList();
            return listret;
        }
        public static string GetBasePathJs()
        {
            var url = HttpContextCore.Current.Request.Path.ToString();
            Ibase_helpconfigBusiness _base_helpconfigBus = AutofacHelper.GetScopeService<Ibase_helpconfigBusiness>();
            var helper = _base_helpconfigBus.GetIQueryable().Where(t => t.HelpConfigUrl == url && t.HelpType == "JS" && t.StatusFlag == "1").FirstOrDefault();
            if (helper.IsNullOrEmpty())
            {
                return "";
            }
            else
            {
                return helper.HelpContent;
            }
        }
    }
}
